package zyh.servlet;

import javafx.application.Application;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintStream;

@WebServlet(name = "TestListenerServlet",urlPatterns = "/listener")
public class TestListenerServlet extends HttpServlet {

//    s@Override
//    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
////        super.doGet(req, resp);
//        ServletContext application=super.getServletContext();
//        application.setAttribute("number",0);
//        resp.setContentType("text/html;charSet=utf-8");
//        PrintStream out=new PrintStream(resp.getOutputStream());
//        out.println("成功访问TestLitenerServlet");
//    }
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext application=super.getServletContext();
        application.setAttribute("number",0);
        application.removeAttribute("");
        resp.setContentType("text/html;charSet=utf-8");
        PrintStream out=new PrintStream(resp.getOutputStream());
        out.println("成功访问TestLitenerServlet");
    }
}
